package cn.wenzy.aurora.admin.modules.organization.controller;

import cn.hutool.core.util.StrUtil;
import cn.wenzy.aurora.admin.modules.organization.bean.SysUser;
import cn.wenzy.aurora.admin.modules.organization.service.SysUserService;
import cn.wenzy.aurora.framework.bean.PageVO;
import cn.wenzy.aurora.framework.controller.IController;
import cn.wenzy.aurora.framework.response.ResponseResult;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.validation.constraints.NotBlank;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sys/user")
public class SysUserController extends IController<SysUserService> {

    @GetMapping("get")
    public ResponseResult<SysUser> get(String userCode) {
        if (StrUtil.isBlank(userCode)) {
            return success();
        }
        SysUser sysUser = service.getById(userCode);
        return success(sysUser);
    }

    @GetMapping("page")
    public ResponseResult<List<SysUser>> page(SysUser sysUser, PageVO pageVO) {
        IPage<SysUser> page = service.page(sysUser, toIPage(pageVO));
        return success(page);
    }

    @GetMapping("list")
    public ResponseResult<List<SysUser>> list(SysUser sysUser) {
        List<SysUser> list = service.list(sysUser);
        return success(list);
    }
}
